import React, {
    Component,
} from 'react';

import {
    StyleSheet,
    Text,
    View,
    Platform,
    FlatList,
    Dimensions,
    TouchableOpacity,
    Image,
    ScrollView,
    StatusBar,
    Linking,
    ActivityIndicator,
    DeviceEventEmitter,
    TextInput,
    Keyboard,
    KeyboardAvoidingView, ImageBackground
} from 'react-native';

import Constant from '../../utils/Constant'//全局变量
import { getImgUrl } from '../../utils/ComFunction';
import HttpUtils from "../../utils/HttpUtils";
import HttpUrls from "../../utils/HttpUrls";
import Header from "../../components/header";
import Loading from "../../utils/Loading";

import AndroidModule from "../../utils/AndroidConnent";
import AudioRecordPage from './AudioRecordPage';
import moment from 'moment';
import SelectOrderPop from './SelectOrderPop';
import SelectStaffPop from './SelectStaffPop'

const isIos = Platform.OS == 'ios';

import OpenIMSDKRN, { OpenIMEmitter, MessageItem } from 'open-im-sdk-rn';
import { ToastToUser } from '../../utils/CustomToast';
import ImageCropPicker from 'react-native-image-crop-picker';
import ImUpload from '../../components/upload/ImUpload'
import ChatImagePriver from '../../components/Tool/ChatImagePriver'
import AsyncImage from '../../components/image/AsyncImage';
import { OrderStatus, AfterSaleStatus } from '../../utils/Enum'

/**
 *  apiAddr: 'http://im-dev.shuaiche.com',
    wsAddr: 'ws://116.62.173.165:5011',
 */
// const apiAddr = 'https://im.shuaiche.com';
// const wsAddr = 'wss://imws.shuaiche.com';

// const apiAddr = 'http://im-dev.shuaiche.com';
// const wsAddr = 'wss://imws-dev.shuaiche.com';

let navigation = null

/**
 * 聊天界面 测试群id：2986836846
 */
export default class MessageChat extends Component {
    constructor(props) {
        super(props);
        let imGroupId = this.props.route.params.imGroupId + ''
        if (imGroupId.startsWith('sg_')) {
            imGroupId = imGroupId.replace('sg_', '')

        }
        this.state = {
            groupId: imGroupId,
            carId: this.props.route.params.carId ? this.props.route.params.carId : '',
            orderNo: '',//this.props.route.params.orderNo ? this.props.route.params.orderNo : '',
            quotationRecordId: this.props.route.params.quotationRecordId ? this.props.route.params.quotationRecordId : '',
            inputText: '',//输入的文本
            isShowBottomBtn: false,//是否显示底部按钮
            operationID: Constant.userInfo.username,//操作ID
            lastMinSeq: '',//用于下一次请求本地消息参数
            startClientMsgID: '',//起始的消息 clientMsgID，第一次拉取为""，后续为上一次拉取的最后一条消息的 clientMsgID
            messageList: [],
            isEableGetLocalMessage: true,
            selectFileIndex: 0,//0选图片 1选文件
            carTitle: '',//车辆标题
            carPrice: '',//车辆价格
            carImg: '',//车辆图片
            isSendingMsg: false,//是否正在发送消息
            isLoadMoreMsg: false,
            showOrderPop: false,
            type: 0,//0买家消息 1卖家消息

            sellerMerchantId: '',
            buyerMerchantId: '',
            buyerUserId: '',
            sellerUserId: '',
            isShowStaffPop: false,
            keyBoardShow: false,
            topTitle: '消息',
            sellerMerchantName: '',
            buyerMerchantName: '',
            quotationPrice: '',

            currentImgUrl: '',
            imageSize: { width: 0, height: 0 },
            showBigImageContainer: false,
            isShowCreateOrderBtn: false,
            quotationRecordData: {},//最新的报价单相关信息

            isFranchisee: 0,
            conversationType: -1,//0联盟交易会话 1报价中心会话
            orderDetailInfo: {},

            showMenu: false,

            // 聊天对面信息
            userFullname: null,
            userPhone: null,


        }
    }

    keyboardWillShow() {
        this.setState({
            keyBoardShow: true,
            isShowBottomBtn: false
        });
    }
    keyboardWillHide() {
        this.setState({
            keyBoardShow: false
        });
    }


    componentWillMount() {

        this.keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow.bind(this));
        this.keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide.bind(this));

        this.uploadSuccessListener = DeviceEventEmitter.addListener('uploadIMSuccess', e => {

            console.log('uploadIMSuccess', e)

            if (this.state.isSendingMsg) {
                return
            }
            if (e.fileOssPath != '' && e.fileOssPath.endsWith('mp4')) {
                this.sendVideoMessage(e.fileOssPath)
            } else if (e.fileOssPath != '') {
                this.sendFileMessage(e.fileName, e.fileOssPath)
            }

        })
        this.selectCarResultListener = DeviceEventEmitter.addListener('selectCarResultListener', (result) => {
            //选择车辆回调
            console.log('selectCarResultListener', result)
            let carInfo = {
                carId: result.carId,
                carTitle: result.carTitle,
                carPrice: result.carPrice,
                mainPic: getImgUrl(result.mainPic),
                mile: result.mile,
                registerDate: result.registerDate,
                merchantId: result.merchantId + ''
            }

            this.sendCustomMessage('1', JSON.stringify(carInfo), '车辆信息')
        })

        this.commonEvent = DeviceEventEmitter.addListener('commonEvent', (data) => {
            if (data.type == 'offerPriceConfrimSuccess') {
                setTimeout(() => {
                    this.getLatestRecordsByConversationId()
                }, 1000);
            }
        })


        this.initSDK()
    }

    addMsgListener() {
        OpenIMEmitter.addListener('onRecvNewMessages', (data) => {
            console.log('onRecvNewMessages', data);
            if (data) {
                let groupMsgs = []
                data.map((item) => {
                    if (item.groupID == this.state.groupId && (item.contentType == 101 || item.contentType == 102 || item.contentType == 103 ||
                        item.contentType == 104 || item.contentType == 105 || item.contentType == 110)) {
                        groupMsgs.push(item)
                    }

                })

                let temp = this.state.messageList.concat(groupMsgs)
                this.setState({
                    messageList: temp
                })

                setTimeout(() => {
                    this._scrollEnd()
                }, 200)
                if (this.state.conversationType == 1) {
                    this.getLatestRecordsByConversationId()

                    if (this.state.quotationRecordId && this.state.quotationRecordId != '') {

                        this.getByquotationRecordId(this.state.quotationRecordId)
                    }
                }

            }

        });
        OpenIMEmitter.addListener('onConnecting', () => {
            console.log('OpenIMEmitter', 'onConnecting');
        });

        OpenIMEmitter.addListener('onConnectSuccess', () => {
            console.log('OpenIMEmitter', 'onConnectSuccess');
            setTimeout(() => {
                if (this.state.messageList.length == 0) {
                    // this.getLocalChatMessage('', '');
                    this.setState({ isLoadMoreMsg: true })
                    this.refreshListData()
                }
            }, 300)

        });

        OpenIMEmitter.addListener('onConnectFailed', ({ errCode, errMsg }) => {
            console.log('OpenIMEmitter', 'onConnectFailed', errCode, errMsg);
        });
    }

    componentWillUnmount() {
        // OpenIMSDKRN.unInitSDK(this.state.operationID)
        // OpenIMEmitter.removeAllListeners('onRecvNewMessages');
        OpenIMEmitter.removeAllListeners('onConnecting');
        OpenIMEmitter.removeAllListeners('onConnectSuccess');
        OpenIMEmitter.removeAllListeners('onConnectFailed');
        if (this.selectCarResultListener) {
            this.selectCarResultListener.remove();
        }
        if (this.uploadSuccessListener) {
            this.uploadSuccessListener.remove();
        }
        if (this.commonEvent) {
            this.commonEvent.remove();
        }

        this.keyboardWillShowListener.remove();
        this.keyboardWillHideListener.remove();

    }


    componentDidMount() {
        console.log('operationID=', this.state.operationID);
        console.log('IMUserId=', Constant.userInfo.imUserId);

        console.log('groupId=', this.state.groupId);
        console.log('carId=', this.state.carId);

        console.log('quotationRecordId==11=', this.state.quotationRecordId);

        //ios首次录音会出现录入为空的问题，这里要先这样处理一下
        // if (isIos) {
        //     setTimeout(() => {
        //         AndroidModule.testAudioRecord()
        //     }, 2000);
        // }


        if (this.Loading) {
            this.Loading.show();
        }

        setTimeout(() => {

            this.getConversationInfo()
        }, 1200);

        if (this.state.quotationRecordId && this.state.quotationRecordId != '') {
            setTimeout(() => {

                this.getByquotationRecordId(this.state.quotationRecordId)
            }, 1200);

        }


    }

    initSDK() {
        this.addMsgListener();
        this.openImLogin();
    };

    openImLogin() {
        OpenIMSDKRN.getLoginStatus(this.state.operationID).then((result) => {
            console.log('getLoginStatus', result);
            if (result == 1) {
                OpenIMSDKRN.login({
                    userID: Constant.userInfo.imUserId,
                    token: Constant.userInfo.imToken,
                }, this.state.operationID)
                    .then((result) => {
                        console.log('login-success', result);
                        // this.getLocalChatMessage('', '');
                        this.setState({ isLoadMoreMsg: true })
                        this.refreshListData()
                        this.markMessageAsRead()
                    }).catch(err => {
                    console.log('login-error=', err);
                });
            } else if (result == 3) {
                // this.getLocalChatMessage('', '');
                this.setState({ isLoadMoreMsg: true })
                this.refreshListData()
                this.markMessageAsRead()
            }
        })

    }

    markMessageAsRead() {

        OpenIMSDKRN.markConversationMessageAsRead('sg_' + this.state.groupId, this.state.operationID)
            .then(() => {
                // 调用成功
                console.log('markConversationMessageAsRead', 'markConversationMessageAsRead', 'groupId=', this.state.groupId);
                DeviceEventEmitter.emit('updateUnreadMsg', {});
            })
            .catch(({ errCode, errMsg }) => {
                // 调用失败
                console.log('markConversationMessageAsRead', errCode, errMsg);
            });
    }

    getLocalChatMessage(startClientMsgID, lastMinSeq) {
        OpenIMSDKRN.getAdvancedHistoryMessageList({
            lastMinSeq: lastMinSeq,
            count: 20,
            startClientMsgID: startClientMsgID,
            conversationID: 'sg_' + this.state.groupId,
        }, this.state.operationID).then((result) => {

            this.setState({
                isLoadMoreMsg: false
            })

            if (result.messageList && result.messageList.length > 0) {
                let clientMsgID = result.messageList[0].clientMsgID

                let msgList = []
                result.messageList.map((item, index) => {
                    /**
                     * 101	文本消息
                     102	图片消息
                     103	语音消息
                     104	视频消息
                     105	文件消息
                     106	@消息
                     107	合并消息
                     108	名片消息
                     109	位置消息
                     110	自定义消息
                     */
                    if (item.contentType == 101 || item.contentType == 102 || item.contentType == 103 ||
                        item.contentType == 104 || item.contentType == 105 || item.contentType == 110 || item.contentType == 1501 || item.contentType == 1509) {
                        msgList.push(item)
                    }
                })
                let temp = msgList.concat(this.state.messageList)
                this.setState({
                    lastMinSeq: result.lastMinSeq,
                    isEableGetLocalMessage: result.isEnd ? false : true,
                    messageList: temp,
                    startClientMsgID: clientMsgID
                })

                if (startClientMsgID == '' && lastMinSeq == '') {
                    setTimeout(() => {
                        this._scrollEnd();
                    }, 500)

                }

                // if (temp.length > 0) {
                //     console.log('getAdvancedHistoryMessageList', temp[temp.length - 2]);
                // }

            }

        }).catch(err => {
            this.setState({
                isLoadMoreMsg: false
            })
            console.log('getAdvancedHistoryMessageList-error=', err);
        });
    }


    render() {
        navigation = this.props.navigation;
        let behavior = Platform.OS == 'ios' ? 'padding' : 'height';
        return (
            <KeyboardAvoidingView style={styles.container} behavior={behavior}  >

                <Header navigation={navigation} Title={this.state.topTitle} RightButton={() => this.renderRightButton()}></Header>

                {/* {this.state.carId && this.state.carId != '' ? this.renderCarInfo() : null} */}
                {this.state.orderNo && this.state.orderNo != '' ? this.renderOrderInfo() : this.state.carId && this.state.carId != '' ? this.renderCarInfo() : null}

                {this.renderMessageList()}

                {this.renderBottomInput()}


                {
                    this.state.showOrderPop ?
                        <SelectOrderPop
                            type={this.state.type}
                            onClose={() => {
                                this.setState({
                                    showOrderPop: false
                                })
                            }}
                            resultCallback={(orderItem) => {
                                this.setState({
                                    showOrderPop: false
                                })
                                this.sendOrderMessage(orderItem)
                            }}
                        />
                        :
                        null
                }


                {
                    this.state.isShowStaffPop ?
                        <SelectStaffPop

                            onClose={() => {
                                this.setState({
                                    isShowStaffPop: false
                                })
                            }}
                            resultCallback={(result) => {
                                this.setState({
                                    isShowStaffPop: false
                                })
                                this.transferConversationUser(result.userId)
                            }}
                        />
                        :
                        null
                }

                {
                    this.state.showBigImageContainer ?
                        <ChatImagePriver
                            imageUrl={this.state.currentImgUrl}
                            imageSize={this.state.imageSize}
                            closeHandler={(index) => {
                                this.setState({
                                    showBigImageContainer: false
                                })
                            }}
                        />
                        :
                        null
                }

                <AudioRecordPage
                    onRef={(ref) => (this.AudioRecordPage = ref)}
                    audioRecordResult={this.audioRecordResult.bind(this)}
                    audioRecordHasShow={this.audioRecordHasShow.bind(this)}
                />


                {
                    this.state.showMenu ?
                        <TouchableOpacity
                            style={styles.moreItemsBg}
                            onPress={() => {
                                this.setState({
                                    showMenu: false
                                })
                            }}
                            activeOpacity={1.0}
                        >
                            <ImageBackground style={[styles.moreItemsBox, { top: isIos ? Constant.statusBarHeight + 20 : 20 }]} source={require('source/image/weibao/more_items.png')}>
                                <TouchableOpacity
                                    style={styles.itemBox}
                                    onPress={() => {
                                        navigation.navigate('CompanyDetailPage', {
                                            merchantId: this.state.sellerMerchantId,
                                            isFranchisee: this.state.isFranchisee
                                        })
                                    }}
                                >
                                    <Text style={styles.itemText}>商家主页</Text>
                                </TouchableOpacity>

                                <View style={styles.sepLine} />
                                <TouchableOpacity
                                    style={styles.itemBox}
                                    onPress={() => {
                                        this.setState({
                                            showMenu: false
                                        })
                                        navigation.navigate('InFormPage', {
                                            userFullname: this.state.userFullname,
                                            userPhone: this.state.userPhone,
                                        })
                                    }}
                                >
                                    <Text style={styles.itemText}>举报</Text>
                                </TouchableOpacity>
                            </ImageBackground>
                        </TouchableOpacity>
                        :
                        null
                }

                <Loading onRef={(ref) => (this.Loading = ref)} />
            </KeyboardAvoidingView>
        );
    }

    sendOrderMessage(orderItem) {
        let orderInfo = {
            orderNo: orderItem.orderNo,
            carTitle: orderItem.carSeriesName + ' ' + orderItem.carSpeciesName,
            mainPic: orderItem.carMainPic,
            createTime: orderItem.createTime,
            carPrice: (orderItem.tradePrice / 10000).toFixed(2) + '万',
        }

        this.sendCustomMessage('2', JSON.stringify(orderInfo), '订单信息')
    }

    audioRecordResult(result) {
        this.AudioRecordPage.hide()
        setTimeout(() => {
            this.sendSoundMessage(result.url, result.second)
        }, 250);
    }

    audioRecordHasShow() {
        this.textInput.blur()
        this.setState({
            isShowBottomBtn: false
        })
    }

    renderRightButton() {
        return (
            <View style={styles.moreContainer}>
                {/*<TouchableOpacity*/}
                {/*    style={styles.moreIconContain}*/}
                {/*    activeOpacity={0.8}*/}
                {/*    onPress={() => {*/}
                {/*        navigation.navigate('CompanyDetailPage', {*/}
                {/*            merchantId: this.state.sellerMerchantId,*/}
                {/*            isFranchisee: this.state.isFranchisee*/}
                {/*        })*/}
                {/*    }}>*/}
                {/*    <Image style={styles.moreIcon} source={require('source/image/imStore.png')} />*/}
                {/*</TouchableOpacity> */}


                <TouchableOpacity
                    style={styles.moreIconContain}
                    activeOpacity={0.8}
                    onPress={() => {
                        this.moreAction()
                    }}>
                    <Image style={styles.moreIcon} source={require('source/image/more_icon.png')} />
                </TouchableOpacity>


                {/* <TouchableOpacity
                    style={styles.moreIconContain}
                    activeOpacity={0.8}
                    onPress={() => {
                        this.setState({
                            isShowStaffPop: true
                        })
                    }}>
                    <Image style={styles.moreIcon} source={require('source/image/imShare.png')} />
                </TouchableOpacity> */}
            </View>

        )
    }

    moreAction() {
        this.setState({
            showMenu: true
        })
    }

    renderCarInfo() {
        return (
            <View style={styles.carInfoContain}>
                <AsyncImage style={styles.carImgStyle} source={{ uri: getImgUrl(this.state.carImg) }} />
                <View style={{ flex: 1, height: 52, justifyContent: 'center', marginRight: 10 }}>
                    <Text style={styles.carTitleText} numberOfLines={1} ellipsizeMode={'tail'}>{this.state.carTitle}</Text>

                    {this.state.conversationType == -1 ?
                        null
                        :
                        this.state.conversationType == 1 ?
                            <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 8 }}>
                                <Text style={{ fontSize: 10, color: '#999999' }}>挂牌价：<Text style={styles.carPriceText}>{this.state.carPrice ? (this.state.carPrice / 10000).toFixed(2) + '万' : '未定价'}</Text></Text>

                                <Text style={{ fontSize: 10, color: '#999999' }}>{this.getPriceText()}<Text style={styles.carPriceText}>{this.state.quotationPrice ? ((this.state.quotationPrice / (10000 * 100)).toFixed(2) + '万') : '未报价'}</Text></Text>
                            </View>
                            :
                            <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 8 }}>
                                <Text style={{ fontSize: 10, color: '#999999' }}>一口价：<Text style={styles.carPriceText}>{this.state.carPrice ? (this.state.carPrice / 10000).toFixed(2) + '万' : '未定价'}</Text></Text>


                            </View>
                    }


                </View>
                <TouchableOpacity
                    style={styles.carInfoBtn}
                    onPress={() => {
                        if (this.state.conversationType == 1) {
                            this.props.navigation.navigate('CarOfferPriceDetailPage', { carId: this.state.carId, merchantId: this.state.sellerMerchantId })
                        } else {
                            navigation.navigate('CarDetailPage', {
                                carId: this.state.carId,

                                merchantId: this.state.sellerMerchantId,

                            })
                        }

                    }}>
                    <Text style={styles.carInfoBtnText}>查看详情</Text>
                </TouchableOpacity>
            </View>
        )
    }

    getPriceText() {
        if ((this.state.quotationRecordData && this.state.quotationRecordData.historyRO
            && this.state.quotationRecordData.historyRO.quotationMerchantId == Constant.userInfo.merchantId)) {
            return '我方报价：'
        } else {
            return '对方报价：'
        }
    }

    renderOrderInfo() {
        return (
            <View style={styles.carInfoContain}>
                <Image style={styles.carImgStyle} source={{ uri: getImgUrl(this.state.carImg) }}></Image>
                <View style={{ flex: 1, height: 52, justifyContent: 'space-between', marginRight: 10 }}>
                    <Text style={styles.carTitleText} numberOfLines={1} ellipsizeMode={'tail'}>{this.state.carTitle}</Text>
                    <Text style={styles.carPriceText}>成交价：{(this.state.quotationPrice / (10000 * 100)).toFixed(2)}万</Text>
                </View>
                <TouchableOpacity
                    style={styles.carInfoBtn}
                    onPress={() => {
                        navigation.navigate('NormalOrderDetail', {
                            orderNo: this.state.orderNo,
                        })
                    }}
                >
                    <Text style={styles.carInfoBtnText}>订单详情</Text>
                </TouchableOpacity>
            </View>
        )
    }


    renderMessageList() {
        return (
            <View style={styles.messageListContain}>
                <FlatList
                    ref={ref => (this.flatlist = ref)}
                    data={this.state.messageList}
                    renderItem={this.renderMessageItem.bind(this)}
                    keyExtractor={(item, index) => index + ''}
                    extraData={this.state}
                    onRefresh={this.refreshListData}

                    refreshing={this.state.isLoadMoreMsg}
                />
            </View>
        )
    }

    refreshListData = () => {
        console.log('refreshListData', 'refreshListData');
        this.getLocalChatMessage(this.state.startClientMsgID, this.state.lastMinSeq);
    }

    _scrollEnd = () => {
        if (this.flatlist) {

            this.flatlist.scrollToEnd({ animated: false });
        }

    }

    renderMessageItem({ item, index }) {
        if (item.sendID == Constant.userInfo.imUserId) {//发送出去的消息
            return (
                <View style={{ width: '100%' }}>
                    {this.isOnlyShowText(item) ?
                        <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center' }}>
                            <View>
                                <Text style={styles.msgItemTimeTextWithBg}>{this.getCommonSubText(JSON.parse(item.customElem.extension))}</Text>
                            </View>

                        </View>
                        :
                        <Text style={styles.msgItemTimeText}>{this.getSendTimeStr(item)}</Text>
                    }

                    {this.isOnlyShowText(item) ? null :
                        <View key={index} style={styles.msgSendItemContain}>
                            {this.getSendMessageItem(item, index)}

                            <AsyncImage style={styles.headImgStyle} source={{ uri: getImgUrl(item.senderFaceUrl) }} />
                        </View>
                    }


                </View>

            )

        } else {//接收到的消息
            return (
                <View style={{ width: '100%' }}>


                    {this.isOnlyShowText(item) ?
                        <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center' }}>
                            <View>
                                <Text style={styles.msgItemTimeTextWithBg}>{this.getCommonSubText(JSON.parse(item.customElem.extension))}</Text>
                            </View>

                        </View>
                        :
                        <Text style={styles.msgItemTimeText}>{this.getSendTimeStr(item)}</Text>
                    }


                    {this.isOnlyShowText(item) || item.contentType == 1501 || item.contentType == 1509 || item.contentType == 1502
                    || item.contentType == 1504 || item.contentType == 1508 || item.contentType == 1510 ? null :
                        <View key={index} style={styles.msgReceiveItemContain}>
                            <AsyncImage style={styles.headImgStyle} source={{ uri: getImgUrl(item.senderFaceUrl) }} />

                            <View style={{ marginLeft: 8, flex: 1 }}>
                                <Text style={styles.msgItemRecvNameText}>{item.senderNickname}</Text>
                                {this.getReceiveMessageItem(item, index)}

                            </View>

                            <View style={{ width: 40 }}></View>

                        </View>
                    }

                </View>

            )
        }

    }

    isOnlyShowText(item) {
        if (item.contentType == 110) {
            let type = item.customElem.data

            if (type == '6') {
                return true
            } else {
                return false
            }
        } else {
            return false
        }
    }

    getOnlyShowText(item) {
        let itemInfo = JSON.parse(item.customElem.extension)
    }

    getSendTimeStr(item) {


        if (item.contentType == 1501) {
            return '可以开始聊天了'
        } else if (item.contentType == 1509) {

            let notificationElem = item.notificationElem
            let detailInfo = JSON.parse(notificationElem.detail)
            if (detailInfo.invitedUserList && detailInfo.invitedUserList.length > 0) {
                return detailInfo.invitedUserList[0].nickname + '进入群聊'
            }
            return '新成员进群通知'
        } else if (item.contentType == 1502 || item.contentType == 1504 || item.contentType == 1508 || item.contentType == 1510) {
            return '系统其他消息'
        }
        else {
            if (this.isToday(item.sendTime)) {
                return '今天 ' + moment(item.sendTime).format("HH:mm")
            } else {
                return moment(item.sendTime).format("MM-DD HH:mm")
            }
        }


    }

    isToday(timestamp) {
        const now = new Date();
        const date = new Date(timestamp);

        return (
            date.getDate() === now.getDate() &&
            date.getMonth() === now.getMonth() &&
            date.getFullYear() === now.getFullYear()
        );
    }

    // 发送的消息样式
    getSendMessageItem(item, index) {
        if (item.contentType == 101) {//文本消息
            return (
                <View style={styles.msgSendItemTextContain}>
                    <Text style={styles.messageItemText}>{item.textElem.content}</Text>
                </View>

            )
        }
        else if (item.contentType == 102) {//图片消息
            let imgItem = item.pictureElem.sourcePicture
            if (imgItem.width > imgItem.height) {//横屏图片
                return (
                    <TouchableOpacity
                        onPress={() => {
                            this.previewImg(item.pictureElem.sourcePicture.url)
                        }}>
                        <AsyncImage style={{ width: 180, height: (180 * imgItem.height / imgItem.width), borderRadius: 6, marginRight: 8 }} source={{ uri: item.pictureElem.sourcePicture.url }} />

                    </TouchableOpacity>

                )
            } else {//竖屏图片
                return (
                    <TouchableOpacity
                        onPress={() => {
                            this.previewImg(item.pictureElem.sourcePicture.url)
                        }}>
                        <AsyncImage style={{ width: 100, height: imgItem.height == 0 ? 100 : (100 * imgItem.height / imgItem.width), borderRadius: 6, marginRight: 8 }} source={{ uri: item.pictureElem.sourcePicture.url }} />

                    </TouchableOpacity>

                )
            }

        }
        else if (item.contentType == 103) {//语音消息
            return (
                <TouchableOpacity style={styles.sendSoundMsgContain}
                                  onPress={() => {
                                      AndroidModule.palyAudio(item.soundElem.sourceUrl)

                                  }}>
                    <Text style={styles.soundTimeText}>{item.soundElem.duration + "\""}</Text>
                    <Image style={styles.soundIconStyle} source={require('source/image/imVoiceTag.png')}></Image>
                </TouchableOpacity>

            )
        }
        else if (item.contentType == 104) {//视频消息
            return (
                <TouchableOpacity style={styles.msgItemVideoContain}
                                  onPress={() => {
                                      Linking.openURL(item.videoElem.videoUrl);
                                  }}>
                    <AsyncImage style={styles.videoImgStyle} source={{ uri: item.videoElem.snapshotUrl }} />
                    <Image style={styles.videoIconStyle} source={require('source/image/imVideoIcon.png')}></Image>
                </TouchableOpacity>

            )
        }
        else if (item.contentType == 105) {//文件消息
            return (
                <TouchableOpacity style={styles.msgItemFileContain}
                                  onPress={() => {
                                      Linking.openURL(item.fileElem.sourceUrl);
                                  }}>
                    <Image style={styles.fileIconStyle} source={require('source/image/imFileTag.png')}></Image>
                    <View>
                        <Text style={styles.fileNameText} numberOfLines={1} ellipsizeMode='tail'>{item.fileElem.fileName}</Text>
                        <Text style={styles.fileTypeText}>{item.fileElem.fileType}</Text>
                    </View>

                </TouchableOpacity>

            )
        }

        else if (item.contentType == 110) {//自定义消息
            let type = item.customElem.data
            let itemInfo = JSON.parse(item.customElem.extension)
            if (type == 1) {
                return (
                    <TouchableOpacity style={styles.commonSendItemContain}
                                      onPress={() => {
                                          navigation.navigate('CarDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })

                                      }}>
                        <View style={{ flexDirection: 'row' }}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: itemInfo.mainPic }} />
                            <View style={{ marginLeft: 5 }}>
                                <Text style={styles.carItemTitleText} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.carTitle}</Text>
                                <Text style={styles.carItemInfoText} >{itemInfo.mile + ' | ' + itemInfo.registerDate}</Text>
                                <Text style={styles.carItemPriceText} >{'展厅价：' + itemInfo.carPrice}</Text>
                            </View>
                        </View>

                    </TouchableOpacity>

                )
            }
            else if (type == 2) {//车辆订单
                return (
                    <TouchableOpacity style={styles.orderSendItemContain}
                                      onPress={() => {


                                      }}>
                        <View style={styles.orderItemCarInfoContain}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: getImgUrl(itemInfo.mainPic) }} />
                            <View style={{ marginLeft: 5, maxWidth: 200 }}>
                                <Text style={styles.carItemTitleText} numberOfLines={2} ellipsizeMode='tail'>{itemInfo.carTitle}</Text>

                                <Text style={[styles.carItemPriceText, { marginTop: 5 }]} >{'成交价：' + itemInfo.carPrice}</Text>
                            </View>
                        </View>

                        <Text style={styles.orderItemText}>订单号：{itemInfo.orderNo}</Text>
                        <Text style={styles.orderItemText}>创建日期：{itemInfo.createTime}</Text>

                    </TouchableOpacity>

                )
            }
            else if (type == 3 || type == 4 || type == 5) {//报价单
                return (
                    <TouchableOpacity style={styles.commonSendItemContain}
                                      activeOpacity={0.8}
                                      onPress={() => {

                            if (itemInfo.linkUrl && itemInfo.linkUrl != '' && itemInfo.linkUrl.startsWith('http')) {
                                navigation.navigate('WebView', { source: itemInfo.linkUrl });
                            } else {
                                if (type == 3) {//报价单
                                    if (this.isBuyerCanOperate(itemInfo)) {
                                        this.sendPriceOrderClick(itemInfo)
                                    }
                                } else if (type == 4) {//业管订单
                                    if (this.isSendMessageCanOperate(itemInfo)) {

                                        this.sendMessageItemClick(itemInfo)
                                    }
                                } else if (type == 5) {//售后订单
                                    if (this.isAftersaleSendMessageCanOperate(itemInfo)) {

                                        this.aftersaleSendMessageItemClick(itemInfo)
                                    }
                                }

                            }


                        }}>
                        <View style={styles.commonSendContentContain}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: getImgUrl(itemInfo.picUrl) }} />

                            <View style={{ marginLeft: 5, flex: 1 }}>
                                <Text style={styles.commonContentTitleText} numberOfLines={1} ellipsizeMode='tail'>{
                                    this.getCommonSubText(itemInfo)}</Text>

                                {itemInfo.content && itemInfo.content != '' ? <Text style={[styles.commonContentText, { marginTop: 5, fontSize: 12 }]} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.content}</Text> : null}
                                <Text style={[styles.commonContentText, { color: itemInfo.bottomTitleColor, marginTop: 5 }]} >{itemInfo.bottomTitle}</Text>
                            </View>
                        </View>

                        {/* <View style={styles.commonBottomBtnContain}>
                            <View></View>
                            <TouchableOpacity
                                style={styles.commonBottomBtn}
                                onPress={() => {

                                    this.recvBottomClick(type, itemInfo)
                                }}>
                                <Text style={styles.commonBottomBtnText}>去处理</Text>
                            </TouchableOpacity>
                        </View> */}

                    </TouchableOpacity>
                )

            }
            else if (type == 7) {  // 推荐车辆
                return (

                    <TouchableOpacity style={styles.commonSendItemContain}
                                      onPress={() => {
                                          navigation.navigate('CarDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })

                                      }}>
                        <View style={{ flexDirection: 'row' }}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: itemInfo.mainPic }} />
                            <View style={{ marginLeft: 5 }}>
                                <Text style={{ fontSize: 14,
                                    color: '#333333',
                                    fontWeight: 'bold'}} numberOfLines={1} ellipsizeMode='tail'>推荐车辆</Text>
                                <Text style={{fontSize:12, color:'#333333', marginTop: 3, width: 140}} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.carTitle?.replaceAll('#', ' ')}</Text>
                                <Text style={{fontSize:14, color: '#ED542E', marginTop: 5}} >{'挂牌价：' + (itemInfo.carPrice || '未定价')}</Text>
                            </View>
                        </View>

                    </TouchableOpacity>

                    // <TouchableOpacity style={styles.commonRecvItemContain}
                    //                   onPress={() => {
                    //                       navigation.navigate('CarDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })
                    //                   }}>
                    //     <View style={{ flexDirection: 'row' }}>
                    //         <AsyncImage style={styles.carItemImg} source={{ uri: itemInfo.mainPic }} />
                    //         <View style={{ marginLeft: 5 }}>
                    //             <Text style={styles.carItemTitleText} numberOfLines={1} ellipsizeMode='tail'>推荐车辆</Text>
                    //             <Text style={styles.carItemTitleText} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.carTitle}</Text>
                    //             {/*<Text style={styles.carItemInfoText} >{itemInfo.mile + ' | ' + itemInfo.registerDate}</Text>*/}
                    //             <Text style={styles.carItemPriceText} >{'挂牌价1：' + itemInfo.carPrice}</Text>
                    //         </View>
                    //     </View>
                    // </TouchableOpacity>
                )
            }
            else {
                return null
            }

        }
        else {
            return null
        }

    }

    isBuyerCanOperate(itemInfo) {
        if (!itemInfo.params || !itemInfo.params.quotationRecord) {
            return false
        }

        if (!this.state.quotationRecordData.historyRO || !itemInfo.params.quotationRecord.historyRO) {
            return this.state.quotationRecordData.quotationRecordId == itemInfo.params.quotationRecord.quotationRecordId &&
                this.state.quotationRecordData.quotationRecordStatus == itemInfo.params.quotationRecord.quotationRecordStatus
        } else {
            return itemInfo.params && itemInfo.params.quotationRecord && this.state.quotationRecordData.quotationRecordId == itemInfo.params.quotationRecord.quotationRecordId &&
                this.state.quotationRecordData.quotationRecordStatus == itemInfo.params.quotationRecord.quotationRecordStatus &&
                this.state.quotationRecordData.historyRO &&
                this.state.quotationRecordData.historyRO.quotationHistoryId == itemInfo.params.quotationRecord.historyRO.quotationHistoryId &&
                this.state.quotationRecordData.historyRO.isReject == itemInfo.params.quotationRecord.historyRO.isReject
        }

    }

    isSendMessageCanOperate(itemInfo) {
        console.log('senditemInfo=', itemInfo)
        if (!itemInfo.params || !itemInfo.params.quotationOrder) {

            return false
        }
        let quotationOrder = itemInfo.params.quotationOrder

        if (this.state.orderDetailInfo.orderStatus == quotationOrder.orderStatus &&
            this.state.orderDetailInfo.orderNo == quotationOrder.orderNo) {
            return true
        } else {
            return false
        }

    }

    sendMessageItemClick(itemInfo) {
        console.log('sendMessageItemClick')
        let linkUrl = ''
        if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
            itemInfo.userTitle.map((item, index) => {
                if (item.merchantId == Constant.userInfo.merchantId) {
                    linkUrl = item.linkUrl
                }
            })
            if (linkUrl != '') {
                let page = linkUrl.replace('app:', '')

                let quotationOrder = itemInfo.params.quotationOrder
                navigation.navigate(page, {
                    carId: quotationOrder.carId,
                    orderNo: quotationOrder.orderNo,
                    contractNo: quotationOrder.contractNo
                })
            }
        }
    }

    isAftersaleSendMessageCanOperate(itemInfo) {
        console.log('aftersenditemInfo=', itemInfo)
        if (!itemInfo.params || !itemInfo.params.afterSales) {

            return false
        }
        let afterSales = itemInfo.params.afterSales

        if (this.state.afterSaleOrderDetailInfo.afterSalesStatus == afterSales.afterSalesStatus &&
            this.state.afterSaleOrderDetailInfo.afterSalesNo == afterSales.afterSalesNo) {
            return true
        } else {
            return false
        }

    }

    aftersaleSendMessageItemClick(itemInfo) {
        console.log('aftersaleSendMessageItemClick')
        let linkUrl = ''
        if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
            itemInfo.userTitle.map((item, index) => {
                if (item.merchantId == Constant.userInfo.merchantId) {
                    linkUrl = item.linkUrl
                }
            })
            if (linkUrl != '') {
                let page = linkUrl.replace('app:', '')

                let afterSales = itemInfo.params.afterSales
                navigation.navigate(page, {
                    carId: afterSales.carId,
                    orderNo: afterSales.afterSalesNo,
                    contractNo: afterSales.contractNo,
                    from: 'afterSale'
                })
            }
        }
    }

    sendPriceOrderClick(itemInfo) {
        let linkUrl = ''
        if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
            itemInfo.userTitle.map((item, index) => {
                if (item.merchantId == Constant.userInfo.merchantId) {
                    linkUrl = item.linkUrl
                }
            })
            if (linkUrl != '') {
                let page = linkUrl.replace('app:', '')
                console.log('orderinfo=', itemInfo.params.quotationRecord)
                let quotationRecord = itemInfo.params.quotationRecord
                navigation.navigate(page, {
                    carId: quotationRecord.carId, quotationRecordId: quotationRecord.quotationRecordId,
                    merchantId: quotationRecord.sellerMerchantId
                })
            }
        }
    }

    getCommonSubText(itemInfo) {

        let title = ''
        if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
            itemInfo.userTitle.map((item, index) => {
                if (item.merchantId == Constant.userInfo.merchantId) {
                    title = item.title
                }
            })
            if (title == '') {
                title = itemInfo.title
            }
        } else {
            title = itemInfo.title
        }
        return title
    }

    previewImg(imgUrl) {

        this.Loading.show('正在加载...')
        Image.getSize(
            imgUrl,
            (width, height) => {
                this.Loading.hide()
                if (isIos) {
                    this.setState({
                        currentImgUrl: imgUrl,
                        imageSize: { width: width, height: height },
                        showBigImageContainer: true,
                    })
                } else {
                    if (width < 300) {
                        this.setState({
                            currentImgUrl: imgUrl,
                            imageSize: { width: width, height: height },
                            showBigImageContainer: true,
                        })
                    } else {
                        let obj = {
                            picList: [imgUrl],
                            index: 0

                        }
                        AndroidModule.previewImages(obj)
                    }

                }


                console.log(`图片宽度: ${width}, 高度: ${height}`);
                // 在这里可以使用获取到的宽高
            },
            (error) => {
                this.Loading.hide()
                ToastToUser('获取图片失败')
            }
        );

    }

    // 接收到的消息
    getReceiveMessageItem(item, index) {
        if (item.contentType == 101) {
            return (
                <View style={{ flexDirection: 'row' }}>
                    <View style={styles.msgRecvItemTextContain}>
                        <Text style={styles.messageItemText}>{item.textElem.content}</Text>

                    </View>
                    <View style={{ flex: 1 }}></View>
                </View>
            )
        }
        else if (item.contentType == 102) {//图片消息
            let imgItem = item.pictureElem.sourcePicture
            if (imgItem.width > imgItem.height) {//横屏图片
                return (
                    <TouchableOpacity
                        onPress={() => {
                            this.previewImg(item.pictureElem.sourcePicture.url)
                        }}>
                        <AsyncImage style={{ width: 180, height: (180 * imgItem.height / imgItem.width), borderRadius: 6, marginRight: 8 }} source={{ uri: item.pictureElem.sourcePicture.url }} />

                    </TouchableOpacity>

                )
            } else {//竖屏图片
                return (
                    <TouchableOpacity
                        onPress={() => {
                            this.previewImg(item.pictureElem.sourcePicture.url)
                        }}>
                        <AsyncImage style={{ width: 100, height: imgItem.height == 0 ? 100 : (100 * imgItem.height / imgItem.width), borderRadius: 6, marginRight: 8 }} source={{ uri: item.pictureElem.sourcePicture.url }} />

                    </TouchableOpacity>

                )
            }

        }
        else if (item.contentType == 103) {//语音消息
            return (
                <View style={{ flexDirection: 'row' }}>
                    <TouchableOpacity style={styles.sendSoundMsgContain}
                                      onPress={() => {
                                          AndroidModule.palyAudio(item.soundElem.sourceUrl)
                                      }}>
                        <Image style={styles.soundIconStyle} source={require('source/image/imVoiceTagRecv.png')}></Image>
                        <Text style={styles.soundTimeText}>{item.soundElem.duration + "\""}</Text>

                    </TouchableOpacity>
                    <View style={{ flex: 1 }}></View>
                </View>


            )
        }
        else if (item.contentType == 104) {//视频消息
            return (
                <TouchableOpacity style={styles.msgItemVideoContain}
                                  onPress={() => {
                                      Linking.openURL(item.videoElem.videoUrl);
                                  }}>
                    <AsyncImage style={styles.videoImgStyle} source={{ uri: item.videoElem.snapshotUrl }} />
                    <Image style={styles.videoIconStyle} source={require('source/image/imVideoIcon.png')}></Image>
                </TouchableOpacity>

            )
        }
        else if (item.contentType == 105) {//文件消息
            return (
                <TouchableOpacity style={styles.msgItemFileRecvContain}
                                  onPress={() => {
                                      Linking.openURL(item.fileElem.sourceUrl);
                                  }}>
                    <Image style={styles.fileIconStyle} source={require('source/image/imFileTag.png')}></Image>
                    <View>
                        <Text style={styles.fileNameText} numberOfLines={1} ellipsizeMode='tail'>{item.fileElem.fileName}</Text>
                        <Text style={styles.fileTypeText}>{item.fileElem.fileType}</Text>
                    </View>

                </TouchableOpacity>

            )
        }
        else if (item.contentType == 110) {//自定义消息
            let type = item.customElem.data

            let itemInfo = JSON.parse(item.customElem.extension)
            if (type == 1) {
                return (
                    <TouchableOpacity style={styles.commonRecvItemContain}
                                      onPress={() => {
                                          navigation.navigate('CarDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })

                                      }}>
                        <View style={{ flexDirection: 'row' }}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: itemInfo.mainPic }} />
                            <View style={{ marginLeft: 5 }}>
                                <Text style={styles.carItemTitleText} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.carTitle}</Text>
                                <Text style={styles.carItemInfoText} >{itemInfo.mile + ' | ' + itemInfo.registerDate}</Text>
                                <Text style={styles.carItemPriceText} >{'展厅价：' + itemInfo.carPrice}</Text>
                            </View>
                        </View>

                    </TouchableOpacity>

                )
            }
            else if (type == 2) {
                return (
                    <TouchableOpacity style={styles.orderSendItemRecvContain}
                                      onPress={() => {


                                      }}>
                        <View style={styles.orderItemCarInfoContain}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: getImgUrl(itemInfo.mainPic) }} />
                            <View style={{ marginLeft: 5, maxWidth: 210 }}>
                                <Text style={styles.carItemTitleText} numberOfLines={2} ellipsizeMode='tail'>{itemInfo.carTitle}</Text>

                                <Text style={[styles.carItemPriceText, { marginTop: 5 }]} >{'成交价：' + itemInfo.carPrice}</Text>
                            </View>
                        </View>

                        <Text style={styles.orderItemText}>订单号：{itemInfo.orderNo}</Text>
                        <Text style={styles.orderItemText}>创建日期：{itemInfo.createTime}</Text>

                    </TouchableOpacity>

                )
            }
            else if (type == 3 || type == 4 || type == 5) {//报价单
                return (
                    <TouchableOpacity style={styles.commonRecvItemContain}
                                      activeOpacity={0.8}
                                      onPress={() => {
                                          if (itemInfo.linkUrl && itemInfo.linkUrl != '' && itemInfo.linkUrl.startsWith('http')) {
                                              navigation.navigate('WebView', { source: itemInfo.linkUrl });
                                          }

                                          console.log('itemInfo=11111', itemInfo)

                                      }}>
                        <View style={styles.commonSendContentContain}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: getImgUrl(itemInfo.picUrl) }} />

                            <View style={{ marginLeft: 5, flex: 1 }}>
                                <Text style={styles.commonContentTitleText} numberOfLines={1} ellipsizeMode='tail'>{
                                    this.getCommonSubText(itemInfo)}</Text>

                                {itemInfo.content && itemInfo.content != '' ? <Text style={[styles.commonContentText, { marginTop: 3, color: itemInfo.titleColor, fontSize: 12 }]} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.content}</Text> : null}
                                <Text style={[styles.commonBottomText, { color: itemInfo.bottomTitleColor, marginTop: 5 }]} >{itemInfo.bottomTitle}</Text>
                            </View>
                        </View>

                        {this.isRecvMsgCanOperate(type, itemInfo) ?
                            <View style={styles.commonBottomBtnContain}>
                                <View></View>
                                <TouchableOpacity
                                    style={styles.commonBottomBtn}
                                    onPress={() => {

                                        this.recvBottomClick(type, itemInfo)
                                    }}>
                                    <Text style={styles.commonBottomBtnText}>去处理</Text>
                                </TouchableOpacity>
                            </View>
                            :
                            null
                        }
                    </TouchableOpacity>
                )

            }
            else if (type == 7) {  // 推荐车辆
                return (
                    <TouchableOpacity style={styles.commonRecvItemContain}
                                      onPress={() => {
                                          // 买手需要跳转到报价详情
                                          navigation.navigate('CarOfferPriceDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })
                                          // navigation.navigate('CarDetailPage', { carId: itemInfo.carId, merchantId: this.state.sellerMerchantId })
                                      }}>
                        <View style={{ flexDirection: 'row'}}>
                            <AsyncImage style={styles.carItemImg} source={{ uri: itemInfo.mainPic }} />
                            <View style={{ marginLeft: 5 }}>
                                <Text style={{ fontSize: 14,
                                    color: '#333333',
                                    fontWeight: 'bold'}}>推荐车辆</Text>
                                <Text style={{fontSize:12, color:'#333333', marginTop: 3, width: 140}} numberOfLines={1} ellipsizeMode='tail'>{itemInfo.carTitle?.replaceAll('#', ' ')}</Text>
                                <Text style={{fontSize:14, color: '#ED542E', marginTop: 5}} >{'挂牌价：' + (itemInfo.carPrice || '未定价')}</Text>
                            </View>
                        </View>
                    </TouchableOpacity>
                )
            }
            else {
                return null
            }

        }
        else {
            return null
        }

    }

    isRecvMsgCanOperate(type, itemInfo) {

        if (type == '3') {//报价单
            if (!itemInfo.params || !itemInfo.params.quotationRecord) {
                return false
            }
            if (!this.state.quotationRecordData.historyRO || !itemInfo.params.quotationRecord.historyRO) {
                return this.state.quotationRecordData.quotationRecordId == itemInfo.params.quotationRecord.quotationRecordId &&
                    this.state.quotationRecordData.quotationRecordStatus == itemInfo.params.quotationRecord.quotationRecordStatus
            } else {
                return itemInfo.params && itemInfo.params.quotationRecord && this.state.quotationRecordData.quotationRecordId == itemInfo.params.quotationRecord.quotationRecordId &&
                    this.state.quotationRecordData.quotationRecordStatus == itemInfo.params.quotationRecord.quotationRecordStatus &&
                    this.state.quotationRecordData.historyRO &&
                    this.state.quotationRecordData.historyRO.quotationHistoryId == itemInfo.params.quotationRecord.historyRO.quotationHistoryId &&
                    this.state.quotationRecordData.historyRO.isReject == itemInfo.params.quotationRecord.historyRO.isReject

            }
        } else if (type == '4') {//订单
            if (!itemInfo.params || !itemInfo.params.quotationOrder) {
                return false
            }

            let quotationOrder = itemInfo.params.quotationOrder
            // console.info('quotationOrder=', quotationOrder)
            // console.info('quotationOrder.orderStatus=', quotationOrder.orderStatus)
            // console.info('this.state.orderDetailInfo.orderStatus=',this.state.orderDetailInfo.orderStatus)
            // console.info('state.orderDetailInfo.orderNo=',this.state.orderDetailInfo.orderNo)
            // console.info('quotationOrder.orderNo=',quotationOrder.orderNo)
            if (this.state.orderDetailInfo.orderStatus == quotationOrder.orderStatus &&
                this.state.orderDetailInfo.orderNo == quotationOrder.orderNo) {
                console.log('quotationOrder.orderStatus=', quotationOrder.orderStatus)
                if (quotationOrder.orderStatus == OrderStatus.OrderStatusWaitDelivery) {

                    if (Constant.userInfo.isFranchisee == 1) {//卖家
                        if (this.state.orderDetailInfo.shippingConfirm == quotationOrder.shippingConfirm) {
                            return true
                        } else {
                            return false
                        }
                    } else {//买家
                        if (this.state.orderDetailInfo.deliveryConfirm == quotationOrder.deliveryConfirm) {
                            return true

                        } else {
                            return false
                        }
                    }
                } else if (quotationOrder.orderStatus == OrderStatus.OrderStatusWaitReceipt) {
                    return false
                }

                return true
            }

            return false
        } else {

            if (!itemInfo.params || !itemInfo.params.afterSales || !this.state.afterSaleOrderDetailInfo) {
                return false

            }

            let afterSales = itemInfo.params.afterSales

            if (this.state.afterSaleOrderDetailInfo.afterSalesStatus == afterSales.afterSalesStatus &&
                this.state.afterSaleOrderDetailInfo.afterSalesNo == afterSales.afterSalesNo) {

                let linkUrl = ''
                itemInfo.userTitle.map((item, index) => {
                    if (item.merchantId == Constant.userInfo.merchantId) {
                        linkUrl = item.linkUrl
                    }
                })

                if (linkUrl == '') {
                    return false
                }

                return true
            }

            return false
        }

    }

    recvBottomClick(type, itemInfo) {
        console.log('itemInfo=', itemInfo)
        console.log('type=', type)

        if (type == '3') {//报价单
            let linkUrl = ''
            if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
                itemInfo.userTitle.map((item, index) => {
                    if (item.merchantId == Constant.userInfo.merchantId) {
                        linkUrl = item.linkUrl
                    }
                })
                if (linkUrl != '') {
                    console.log('linkUrl=', linkUrl)
                    let page = linkUrl.replace('app:', '')

                    let quotationRecord = itemInfo.params.quotationRecord
                    navigation.navigate(page, {
                        carId: quotationRecord.carId, quotationRecordId: quotationRecord.quotationRecordId,
                        buyerMerchantName: quotationRecord.historyRO ? quotationRecord.historyRO.quotationMerchantName : '',
                        merchantId: quotationRecord.sellerMerchantId
                    })
                }
            }
        } else if (type == '4') {//报价单后续订单
            let linkUrl = ''
            if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
                itemInfo.userTitle.map((item, index) => {
                    if (item.merchantId == Constant.userInfo.merchantId) {
                        linkUrl = item.linkUrl
                    }
                })
                if (linkUrl != '') {
                    let page = linkUrl.replace('app:', '')

                    let quotationOrder = itemInfo.params.quotationOrder
                    navigation.navigate(page, {
                        carId: quotationOrder.carId,
                        orderNo: quotationOrder.orderNo,
                        contractNo: quotationOrder.contractNo
                    })
                }
            }
        } else if (type == '5') {
            let linkUrl = ''
            if (itemInfo.userTitle && itemInfo.userTitle.length > 0) {
                itemInfo.userTitle.map((item, index) => {
                    if (item.merchantId == Constant.userInfo.merchantId) {
                        linkUrl = item.linkUrl
                    }
                })
                if (linkUrl != '') {
                    let page = linkUrl.replace('app:', '')

                    let afterSales = itemInfo.params.afterSales
                    navigation.navigate(page, {
                        carId: afterSales.carId,
                        orderNo: afterSales.afterSalesNo,
                        contractNo: afterSales.contractNo,
                        from: 'afterSale'
                    })
                }
            }
        }
    }

    isCheckShowBottomBtn(itemInfo) {

    }

    renderBottomInput() {
        return (
            <View >
                <View style={styles.bottomInputContain}>
                    <TouchableOpacity
                        style={styles.bottomVoiceBtn}
                        onPress={() => {
                            console.log('bottomVoiceBtn')
                            this.AudioRecordPage.show()
                        }}>
                        <Image style={styles.bottomVoiceImg} source={require('source/image/imVoiceBtn.png')}></Image>
                    </TouchableOpacity>

                    <TextInput
                        style={styles.bottomInputStyle}
                        multiline={true}
                        ref={(textInput) => { this.textInput = textInput }}
                        value={this.state.inputText}
                        onChangeText={(text) => {
                            this.setState({
                                inputText: text
                            })
                        }}>

                    </TextInput>


                    {this.state.inputText == '' ?
                        <TouchableOpacity
                            style={styles.bottomMoreContain}
                            onPress={() => {
                                this.textInput.blur()
                                this.setState({
                                    isShowBottomBtn: !this.state.isShowBottomBtn
                                })
                            }}>
                            <Image style={styles.bottomVoiceImg} source={require('source/image/imBottomMore.png')}></Image>
                        </TouchableOpacity>
                        :
                        <TouchableOpacity
                            style={styles.sendBtn}
                            onPress={() => {
                                this.sendMsg()
                            }}>
                            <Text style={styles.sendBtnText}>发送</Text>
                        </TouchableOpacity>
                    }

                </View>

                {this.state.isShowBottomBtn ?
                    <View style={styles.bottomBtnContain}>
                        <View style={styles.bottomBtnRowContain}>
                            <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {
                                    this.setState({
                                        selectFileIndex: 0
                                    })
                                    this.selectImg()
                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imSendImg.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>发送照片</Text>
                            </TouchableOpacity>
                            <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {
                                    this.setState({
                                        selectFileIndex: 1
                                    })
                                    this.selectFile()
                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imSendFile.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>发送文件</Text>
                            </TouchableOpacity>
                            {/* <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {
                                    this.setState({
                                        showOrderPop: true
                                    })
                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imSendOrder.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>发送订单</Text>
                            </TouchableOpacity> */}
                            <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {
                                    navigation.navigate('SelectShareCarListPage', {
                                        searchParams: { pageSize: 20, pageNo: 1, searchChannel: 'app_index_car', merchantIds: [this.state.sellerMerchantId], joinUnion: 1, saleStatus: '1,2' },
                                        maxCount: 1, fromPage: 'MessageChat'
                                    })

                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imSendCar.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>发送车辆</Text>
                            </TouchableOpacity>
                            <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {
                                    if (this.state.type == '0') {//买家消息

                                        this.getPhoneNumber(this.state.sellerUserId, this.state.sellerMerchantId)
                                    } else {
                                        this.getPhoneNumber(this.state.buyerUserId, this.state.buyerMerchantId)
                                    }
                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imContact.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>电话联系</Text>
                            </TouchableOpacity>
                        </View>

                        <View style={styles.bottomBtnRowContain}>

                            {/* <TouchableOpacity
                                style={styles.bottomBtnItemContain}
                                onPress={() => {

                                }}>
                                <View style={styles.bottomBtnImgContain}>
                                    <Image style={styles.bottomBtnImg} source={require('source/image/imSendContract.png')} />
                                </View>

                                <Text style={styles.bottomBtnText}>发送合同</Text>
                            </TouchableOpacity> */}

                            {Constant.userInfo.isFranchisee == 1 && this.state.isShowCreateOrderBtn ?
                                <TouchableOpacity
                                    style={styles.bottomBtnItemContain}
                                    onPress={() => {
                                        navigation.navigate('StartOrderPage', { carId: this.state.carId, quotationRecordId: this.state.quotationRecordId, buyerMerchantName: this.state.buyerMerchantName })
                                    }}>
                                    <View style={styles.bottomBtnImgContain}>
                                        <Image style={styles.bottomBtnImg} source={require('source/image/msg/imCreateOrder.png')} />
                                    </View>

                                    <Text style={styles.bottomBtnText}>创建订单</Text>
                                </TouchableOpacity>

                                :
                                <View
                                    style={styles.bottomBtnItemContain}
                                >

                                </View>
                            }

                            <View
                                style={styles.bottomBtnItemContain}
                            >

                            </View>
                            <View
                                style={styles.bottomBtnItemContain}
                            >

                            </View>

                            <View
                                style={styles.bottomBtnItemContain}
                            >

                            </View>
                        </View>
                    </View>
                    :
                    null
                }

                {
                    isIos && Constant.isIPhoneX && this.state.keyBoardShow == false ?
                        <View style={{ width: '100%', height: 34 }} />
                        :
                        null
                }


            </View>
        )
    }

    selectImg() {
        // AndroidModule.selectLocalFile({ fileType: 'image' });

        const option = { mediaType: "photo", cropping: false, compressImageQuality: .8, multiple: false, compressImageMaxWidth: 1024, compressImageMaxHeight: 1024 };
        ImageCropPicker.openPicker(option).then(images => {
            if (this.Loading) {
                this.Loading.show('正在上传');
            }
            ImUpload.getAlipz(images.path, ImUpload.ossTypeImage, this.uploadafterfun);//获取阿里凭证。

        }, (error) => {
            // alert(error);
        });

    }

    uploadafterfun = (picUrl) => {
        if (this.Loading) {
            this.Loading.hide();
        }
        this.sendImageMessage(picUrl);
    }

    selectFile() {
        AndroidModule.selectLocalFile({ fileType: '' });
    }

    sendMsg() {
        this.sendTextMessage();
    }

    async sendTextMessage() {
        let that = this
        const message = await OpenIMSDKRN.createTextMessage(this.state.inputText, this.state.operationID);
        console.log('message=', message);
        if (message == null || message == '' || message == undefined) {
            return
        }
        let offlineMsg = {
            title: '您有一条新消息',
            desc: this.state.inputText
        }
        OpenIMSDKRN.sendMessage({
            recvID: '',
            groupID: this.state.groupId,
            message: message,
            offlinePushInfo: offlineMsg
        }, this.state.operationID)
            .then((result) => {
                console.log('sendMessage', '消息发送成功');
                console.log('sendMessage-result', result);
                let temp = that.state.messageList
                temp.push(result)
                that.setState({ inputText: '', messageList: temp });
                setTimeout(() => {

                    console.log('sendMessage', temp[temp.length - 1]);
                    console.log('sendMessage', '_scrollEnd');
                    that._scrollEnd();
                }, 200)
            })
            .catch(err => {

                console.log('sendMessage-error=', err);
            });
    }

    async sendImageMessage(imgUrl) {
        let that = this
        Image.getSize(imgUrl, async (width, height) => {
            let sourcePicture = {
                url: imgUrl,
                width: width,
                height: height
            }
            const message = await OpenIMSDKRN.createImageMessageByURL({
                sourcePicture: sourcePicture,
                bigPicture: sourcePicture,
                snapshotPicture: sourcePicture,
                sourcePath: ''
            }, this.state.operationID);
            console.log('message=', message);
            let offlineMsg = {
                title: '您有一条新消息',
                desc: '图片'
            }
            OpenIMSDKRN.sendMessageNotOss({
                recvID: '',
                groupID: this.state.groupId,
                message: message,
                offlinePushInfo: offlineMsg
            }, this.state.operationID)
                .then((result) => {
                    console.log('sendMessage', '消息发送成功');
                    let temp = that.state.messageList
                    temp.push(result)
                    that.setState({ messageList: temp });
                    setTimeout(() => {

                        console.log('sendMessage', temp[temp.length - 1]);
                        console.log('sendMessage', '_scrollEnd');
                        that._scrollEnd();
                    }, 200)
                })
                .catch(err => {

                    console.log('sendMessage-error=', err);
                });

        }, error => {

        });

    }

    sendFileMessage(fileName, fileOssPath) {
        if (fileName.endsWith('jpg') || fileName.endsWith('png') || fileName.endsWith('jpeg')) {
            this.sendImageMessage(fileOssPath)
        }
        // else if (fileName.endsWith('mp3')) {

        // } 
        else if (fileName.endsWith('mp4')) {
            this.sendVideoMessage(fileOssPath)
        } else {//其他文件
            let ends = ''
            let strs = fileName.split('\.');
            if (strs.length > 1) {
                ends = strs[strs.length - 1]
            }
            console.log('strs=', strs);
            this.sendFileMessageByURL(fileName, fileOssPath, ends)
        }
    }

    async sendVideoMessage(videoUrl) {
        let that = this
        let snapshot = `${videoUrl}?x-oss-process=video/snapshot,t_1,f_jpg,w_800,h_600,m_fast`
        let videoUUID = new Date().getTime() + '' + Constant.userInfo.userId

        const message = await OpenIMSDKRN.createVideoMessageByURL({
            videoPath: '',
            duration: 100,
            videoType: 'mp4',
            snapshotPath: '',
            videoUUID: videoUUID,
            videoUrl: videoUrl,
            videoSize: 100,
            snapshotUUID: videoUUID,
            snapshotSize: 100,
            snapshotUrl: snapshot,
            snapshotWidth: 800,
            snapshotHeight: 600,
            snapShotType: 'jpg',
        }, this.state.operationID)

        console.log('message=', message);
        let offlineMsg = {
            title: '您有一条新消息',
            desc: '视频'
        }
        OpenIMSDKRN.sendMessageNotOss({
            recvID: '',
            groupID: this.state.groupId,
            message: message,
            offlinePushInfo: offlineMsg
        }, this.state.operationID)
            .then((result) => {
                console.log('sendMessage', '视频消息发送成功');
                let temp = that.state.messageList
                temp.push(result)
                that.setState({ messageList: temp });
                setTimeout(() => {

                    console.log('sendMessage', temp[temp.length - 1]);
                    console.log('sendMessage', '_scrollEnd');
                    that._scrollEnd();
                }, 200)
            })
            .catch(err => {

                console.log('sendMessage-error=', err);
            });
    }

    async sendSoundMessage(soundUrl, second) {
        let that = this
        let uuid = new Date().getTime() + '' + Constant.userInfo.userId
        const message = await OpenIMSDKRN.createSoundMessageByURL({
            uuid: uuid,
            soundPath: '',
            sourceUrl: soundUrl,
            dataSize: 1024,
            duration: second,
            soundType: 'mp3',
        }, this.state.operationID)
        console.log('message=', message);
        let offlineMsg = {
            title: '您有一条新消息',
            desc: '音频'
        }
        OpenIMSDKRN.sendMessageNotOss({
            recvID: '',
            groupID: this.state.groupId,
            message: message,
            offlinePushInfo: offlineMsg
        }, this.state.operationID)
            .then((result) => {
                console.log('sendMessage', '视频消息发送成功');
                let temp = that.state.messageList
                temp.push(result)
                that.setState({ messageList: temp });
                setTimeout(() => {

                    console.log('sendMessage', temp[temp.length - 1]);
                    console.log('sendMessage', '_scrollEnd');
                    that._scrollEnd();
                }, 200)
            })
            .catch(err => {

                console.log('sendMessage-error=', err);
            });
    }

    async sendFileMessageByURL(fileName, fileOssPath, fileType) {
        let that = this
        let uuid = new Date().getTime() + '' + Constant.userInfo.userId
        OpenIMSDKRN.createFileMessageByURL({
            filePath: '',
            fileName: fileName,
            uuid: uuid,
            sourceUrl: fileOssPath,
            fileSize: 1024,
            fileType: fileType,
        }, this.state.operationID)
            .then((message) => {
                // 调用成功

                console.log('message=', message);
                let offlineMsg = {
                    title: '您有一条新消息',
                    desc: '文件'
                }
                OpenIMSDKRN.sendMessageNotOss({
                    recvID: '',
                    groupID: this.state.groupId,
                    message: message,
                    offlinePushInfo: offlineMsg
                }, this.state.operationID)
                    .then((result) => {
                        console.log('sendMessage', '视频消息发送成功');
                        let temp = that.state.messageList
                        temp.push(result)
                        that.setState({ messageList: temp });
                        setTimeout(() => {

                            console.log('sendMessage', temp[temp.length - 1]);
                            console.log('sendMessage', '_scrollEnd');
                            that._scrollEnd();
                        }, 200)
                    })
                    .catch(err => {

                        console.log('sendMessage-error=', err);
                    });
            })
            .catch(({ errCode, errMsg }) => {
                // 调用失败
            });
    }

    /**
     * 发送自定义消息
     * @param {文本内容} data
     * @param {拓展内容} extension
     * @param {描述内容} description
     */
    async sendCustomMessage(data, extension, description) {
        let that = this
        const message = await OpenIMSDKRN.createCustomMessage({
            data: data,
            extension: extension,
            description: description
        }, this.state.operationID);
        console.log('message=', message);
        let offlineMsg = {
            title: '您有一条新消息',
            desc: description
        }
        OpenIMSDKRN.sendMessage({
            recvID: '',
            groupID: this.state.groupId,
            message: message,
            offlinePushInfo: offlineMsg
        }, this.state.operationID)
            .then((result) => {
                console.log('sendMessage', '消息发送成功');
                console.log('sendMessage-result', result);
                let temp = that.state.messageList
                temp.push(result)
                that.setState({ inputText: '', messageList: temp });
                setTimeout(() => {

                    console.log('sendMessage', temp[temp.length - 1]);
                    console.log('sendMessage', '_scrollEnd');
                    that._scrollEnd();
                }, 200)
            })
            .catch(err => {

                console.log('sendMessage-error=', err);
            });
    }


    getCarDetails() {
        let param = {
            carId: this.state.carId,
            merchantId: Constant.userInfo.merchantId,
        }

        HttpUtils.getRequest(HttpUrls.getCarDetail, param)
            .then((result) => {
                if (result.code == 0) {
                    this.setState({
                        carTitle: result.data.seriesName + ' ' + result.data.speciesName,
                        carPrice: this.state.conversationType == 1 ? result.data.listPrice : result.data.markedPrice,
                        carImg: result.data.mainPic
                    })

                    // 如果有carPurchaseId 则推送一条车的消息
                    const { carPurchaseId } = this.props.route.params || {};
                    if (carPurchaseId) {
                        let carInfo = {
                            carId: result.data.carId,
                            carTitle: result.data.carName,
                            carPrice: this.state.conversationType == 1 ? result.data.listPrice : result.data.markedPrice,
                            mainPic: getImgUrl(result.data.mainPic),
                            registerDate: result.data.registerDate,
                            merchantId: result.data.merchantId + ''
                        }

                        this.sendCustomMessage('7', JSON.stringify(carInfo), '推荐车辆')
                    }
                }


                if (this.Loading) {
                    this.Loading.hide();
                }
            })
            .catch((error) => {

            });
    }


    getConversationInfo() {
        let param = {
            imConversationId: 'sg_' + this.state.groupId,
            imUserId: Constant.userInfo.imUserId,
        }

        HttpUtils.postRequest(HttpUrls.getOneConversation, param)
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
                console.log('getOneConversation', result);
                this.setState({
                    sellerMerchantId: result.data.sellerMerchantId,
                    buyerMerchantId: result.data.buyerMerchantId,
                    sellerMerchantName: result.data.sellerMerchantName,
                    buyerUserId: result.data.buyerUserId,
                    sellerUserId: result.data.sellerUserId,
                    buyerMerchantName: result.data.buyerMerchantName,
                    conversationType: result.data.conversationType
                })

                //type 0买家消息 1卖家消息

                if (Constant.userInfo.userId == result.data.buyerUserId) {
                    console.log('当前用户ID和买家一致', this.state.type)
                    //当前用户ID和买家一致，是买家消息
                    this.setState({
                        type: '0'
                    }, function () {
                        this.getMerchantDetailInfo(result.data)
                    })

                } else {
                    this.setState({
                        type: '1'
                    }, function () {
                        this.getMerchantDetailInfo(result.data)
                    })
                }

                if (this.state.carId && this.state.carId != '') {
                    this.getCarDetails()
                } else {
                    if (this.Loading) {
                        this.Loading.hide();
                    }
                }

                //报价、订单会话
                if (result.data.conversationType == 1) {
                    this.getLatestRecordsByConversationId()

                }

            })
            .catch((error) => {

            });
    }

    getMerchantDetailInfo(data) {
        if (this.state.type == '0') {//买家消息获取买家商户信息
            this.getMerchantDetail(data.sellerMerchantId)
        } else {
            this.getMerchantDetail(data.buyerMerchantId)
        }
    }

    /**
     * 转移会话信息给其他人
     * @param {*} toUserId
     */
    transferConversationUser(toUserId) {
        let param = {
            imConversationId: 'sg_' + this.state.groupId,
            fromUserId: Constant.userInfo.userId,
            toUserId: toUserId,
            role: this.state.type == '0' ? 2 : 1
        }

        HttpUtils.postRequest(HttpUrls.transferConversationUser, param)
            .then((result) => {
                console.log('getOneConversation', result);
                if (result.success) {
                    AndroidModule.finish();
                } else {
                    ToastToUser(result.msg)
                }
            })
            .catch((error) => {

            });
    }


    getPhoneNumber(userId, merchantId) {
        let param = {
            userId: userId,
            merchantId: merchantId
        }

        HttpUtils.postRequest(HttpUrls.getStaffDetails, param)
            .then((result) => {

                if (result.success) {
                    const url = `tel:${result.data.userPhone}`;
                    Linking.openURL(url);
                } else {
                    ToastToUser(result.msg)
                }
            })
            .catch((error) => {

            });
    }

    getMerchantDetail(merchantId) {
        let param = {
            merchantId: merchantId
        }

        HttpUtils.getRequest(HttpUrls.getMerchantDetail, param)
            .then((result) => {
                this.setState({
                    topTitle: result.data.merchantAbbreviation,
                    isFranchisee: result.data.isFranchisee,
                    userFullname: result.data.userFullname,
                    userPhone: result.data.userPhone,
                })
            })
            .catch((error) => {

            });
    }

    getByquotationRecordId(quotationRecordId) {
        let param = {

            quotationRecordId: quotationRecordId
        }

        HttpUtils.getRequest(HttpUrls.getByquotationRecordId, param)
            .then((result) => {
                this.setState({
                    quotationPrice: result.data.quotationPrice ? result.data.quotationPrice : 0,
                    isShowCreateOrderBtn: result.data.quotationRecordStatus == 0 ||
                        (result.data.quotationRecordStatus == 1 && result.data.historyRO && result.data.historyRO.isReject == 1) || result.data.quotationRecordStatus == 4
                })
            })
            .catch((error) => {

            });
    }

    getLatestRecordsByConversationId() {
        let param = {

            imConversationId: 'sg_' + this.state.groupId
        }

        HttpUtils.getRequest(HttpUrls.getLatestRecordsByConversationId, param)
            .then((result) => {
                if (result.data) {
                    this.setState({
                        quotationRecordData: result.data,
                        quotationPrice: result.data.quotationPrice
                    })
                    console.log('getLatestRecordsByConversationId', result.data)

                    //quotationRecordStatus 3已下单状态去请求订单相关信息

                    if (result.data.quotationRecordStatus == 3) {
                        this.getLatestOrderByImConversationId()
                        this.getLatestAfterSaleOrderByImConversationId()
                    }
                }

            })
            .catch((error) => {

            });
    }

    /**
     * 根据id获取最新的订单信息
     */
    getLatestOrderByImConversationId() {
        let param = {

            imConversationId: 'sg_' + this.state.groupId
        }

        HttpUtils.getRequest(HttpUrls.getLatestOrderByImConversationId, param)
            .then((result) => {
                if (result.data) {
                    this.setState({
                        carTitle: result.data.carName.replaceAll('#', ''),
                        quotationPrice: result.data.quotationAmount,
                        carImg: result.data.mainPic,
                        orderNo: result.data.orderNo,
                        orderDetailInfo: result.data
                    })
                }

            })
            .catch((error) => {

            });
    }

    /**
    * 根据id获取最新的订单信息
    */
    getLatestAfterSaleOrderByImConversationId() {
        let param = {

            imConversationId: 'sg_' + this.state.groupId
        }

        HttpUtils.getRequest(HttpUrls.getLatestAfterSalesByConversationId, param)
            .then((result) => {
                if (result.data) {
                    this.setState({

                        afterSaleOrderDetailInfo: result.data
                    })

                }

            })
            .catch((error) => {

            });
    }

}

const styles = StyleSheet.create({
    container: {
        width: '100%',
        height: '100%',
        flexDirection: 'column',

        backgroundColor: '#fff'
    },
    moreContainer: {
        position: 'absolute',
        right: 0,
        height: 44,
        justifyContent: 'center',
        alignItems: 'center',
        flexDirection: 'row'
    },

    moreIconContain: {
        width: 40,
        height: 44,
        justifyContent: 'center',
        alignItems: 'center',
        marginRight: 10
    },
    moreIcon: {
        width: 24,
        height: 24,
    },

    carInfoContain: {
        width: '100%',
        height: 68,
        flexDirection: 'row',
        alignItems: 'center',
        paddingHorizontal: 15,
        borderBottomColor: '#E4E4E4',
        borderBottomWidth: 0.6
    },
    carImgStyle: {
        width: 52,
        height: 52,
        borderRadius: 4,
        marginRight: 10,
    },

    carInfoBtn: {
        width: 72,
        height: 28,
        borderRadius: 14,
        backgroundColor: '#FFEF3A',
        justifyContent: 'center',
        alignItems: 'center'
    },
    carInfoBtnText: {
        fontSize: 12,
        color: '#333333'
    },
    carTitleText: {
        fontSize: 14,
        color: '#333333'
    },
    carPriceText: {
        fontSize: 14,
        color: '#ED542E'
    },

    messageListContain: {
        flex: 1,
        width: '100%'
    },

    bottomInputContain: {
        width: '100%',
        // height: 53,
        flexDirection: 'row',
        alignItems: 'center',
        borderTopColor: '#E4E4E4',
        borderTopWidth: 0.6
    },

    bottomVoiceBtn: {
        width: 52,
        height: 53,
        justifyContent: 'center',
        alignItems: 'center'
    },
    bottomVoiceImg: {
        width: 28,
        height: 28
    },

    bottomMoreContain: {
        width: 52,
        height: 53,
        justifyContent: 'center',
        alignItems: 'center'
    },

    bottomInputStyle: {
        flex: 1,
        // height:38,
        minHeight: 33,
        borderRadius: 4,
        backgroundColor: '#F4F4F4',
        paddingHorizontal: 10,
        marginTop: 10,
        marginBottom: 10
    },
    bottomVoiceText: {
        fontSize: 14,
        color: '#333333'
    },

    bottomVoicePressBtn: {
        flex: 1,
        height: 40,
        borderRadius: 4,
        backgroundColor: '#F4F4F4',
        justifyContent: 'center',
        alignItems: 'center',
        marginTop: 10,
        marginBottom: 10
    },

    sendBtn: {
        width: 60,
        height: 38,
        borderRadius: 4,
        backgroundColor: '#FFEF3A',
        justifyContent: 'center',
        alignItems: 'center',
        marginRight: 10,
        marginLeft: 10
    },

    sendBtnText: {
        fontSize: 12,
        color: '#333333'
    },

    bottomBtnContain: {
        marginTop: 10
    },

    bottomBtnRowContain: {
        flexDirection: 'row',
        alignItems: 'center',
        marginLeft: 10,
        marginRight: 10,
        marginBottom: 8
    },
    bottomBtnItemContain: {
        justifyContent: 'center',
        alignItems: 'center',
        flex: 1
    },
    bottomBtnImgContain: {
        width: 60,
        height: 60,
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius: 12,
        backgroundColor: '#F4F4F4'
    },
    bottomBtnImg: {
        width: 28,
        height: 28,
    },
    bottomBtnText: {
        fontSize: 12,
        color: '#666666',
        marginTop: 6,
        lineHeight: 20
    },

    msgSendItemContain: {
        flexDirection: 'row',
        justifyContent: 'flex-end',
        paddingLeft: 15,
        paddingRight: 15,
        marginBottom: 15,
        width: '100%'
    },
    headImgStyle: {
        width: 40,
        height: 40,
        borderRadius: 40,
        backgroundColor: '#F4F4F4',
    },

    msgSendItemTextContain: {
        backgroundColor: '#FFE000',
        borderRadius: 8,
        padding: 12,
        marginRight: 8,
        marginLeft: 64

    },
    messageItemText: {
        fontSize: 14,
        color: '#333333'
    },

    msgRecvItemTextContain: {
        backgroundColor: '#f4f4f4',
        borderRadius: 8,
        padding: 12,

        flexDirection: 'row',

    },
    msgReceiveItemContain: {
        flexDirection: 'row',
        paddingLeft: 15,
        paddingRight: 15,
        marginBottom: 15,
        width: '100%'
    },
    msgItemRecvNameText: {
        fontSize: 12,
        color: '#666666',
        marginBottom: 2
    },
    msgItemImgStyle: {
        width: 100,
        height: 40,
        borderRadius: 6,
    },
    msgItemVideoContain: {
        width: 180,
        height: 100,
        borderRadius: 6,
        justifyContent: 'center',
        alignItems: 'center',
        marginRight: 8,
    },
    videoImgStyle: {
        position: 'absolute',
        top: 0,
        left: 0,
        width: '100%',
        height: '100%',
        borderRadius: 6
    },
    videoIconStyle: {
        width: 40,
        height: 40,
    },

    sendSoundMsgContain: {
        backgroundColor: '#FFE000',
        borderRadius: 8,
        padding: 12,
        marginRight: 8,
        flexDirection: 'row',
        alignItems: 'center'
    },
    soundIconStyle: {
        width: 24,
        height: 24,
    },
    soundTimeText: {
        fontSize: 14,
        color: '#333333',
        marginLeft: 5,
        marginRight: 8
    },
    carSendMsgItemContain: {
        flexDirection: 'row',
        alignItems: 'center',
        padding: 12,
        backgroundColor: '#FFE000',
        borderRadius: 8,
        marginLeft: 64,
        marginRight: 8
    },
    carSendMsgItemRecvContain: {
        flexDirection: 'row',
        alignItems: 'center',
        padding: 12,
        backgroundColor: '#f4f4f4',
        borderRadius: 8,
        marginRight: 64
    },
    carItemImg: {
        width: 52,
        height: 52,
        borderRadius: 6
    },
    carItemTitleText: {
        fontSize: 14,
        color: '#333333',
        maxWidth: 172
    },
    carItemInfoText: {
        fontSize: 10,
        color: '#666666',
        marginTop: 3,
        marginBottom: 3
    },
    carItemPriceText: {
        fontSize: 12,
        color: '#ED542E'
    },

    msgItemFileContain: {
        backgroundColor: '#FFE000',
        borderRadius: 8,
        flexDirection: 'row',
        alignItems: 'center',
        padding: 12,
        marginRight: 8,
        marginLeft: 64
    },
    msgItemFileRecvContain: {
        backgroundColor: '#f4f4f4',
        borderRadius: 8,
        flexDirection: 'row',
        alignItems: 'center',
        padding: 12,

    },
    fileIconStyle: {
        width: 44,
        height: 44
    },
    fileNameText: {
        fontSize: 14,
        color: '#333333',
        maxWidth: 200
    },
    fileTypeText: {
        fontSize: 10,
        color: '#666666',
        marginTop: 5
    },
    msgItemTimeText: {
        fontSize: 12,
        color: '#999999',
        textAlign: 'center',
        width: '100%',
        marginTop: 5,
        marginBottom: 10
    },
    msgItemTimeTextWithBg: {
        fontSize: 12,
        color: '#999999',

        paddingLeft: 10,
        paddingRight: 10,
        paddingTop: 5,
        paddingBottom: 5,
        marginTop: 5,
        marginBottom: 10,
        backgroundColor: '#f6f6f6',
        borderRadius: 4

    },
    orderSendItemContain: {
        flexDirection: 'column',

        padding: 12,
        backgroundColor: '#FFE000',
        borderRadius: 8,
        marginLeft: 64,
        marginRight: 8
    },
    orderSendItemRecvContain: {
        flexDirection: 'column',

        padding: 12,
        backgroundColor: '#f4f4f4',
        borderRadius: 8,
        marginRight: 64
    },
    orderItemCarInfoContain: {
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 6
    },
    orderItemText: {
        fontSize: 12,
        color: '#333333',
        marginTop: 4
    },

    commonSendItemContain: {
        flexDirection: 'column',

        padding: 12,
        backgroundColor: '#FFE000',
        borderRadius: 8,
        marginLeft: 55,
        marginRight: 8,
        flex: 1
    },
    commonSendContentContain: {
        flexDirection: 'row',
        width: '100%',

    },
    commonContentText: {
        fontSize: 14,
        color: '#333333'
    },
    commonContentTitleText: {
        fontSize: 14,
        color: '#333333',
        fontWeight: 'bold'
    },

    commonRecvItemContain: {
        flexDirection: 'column',

        padding: 12,
        backgroundColor: '#f4f4f4',
        borderRadius: 8,
        // marginRight: 64,
        marginRight: 8
    },

    commonBottomBtnContain: {
        flexDirection: 'row',
        alignItems: 'center',
        marginTop: 8,
        justifyContent: 'space-between'
    },
    commonBottomBtn: {
        backgroundColor: '#FFE000',
        width: 52,
        height: 21,
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius: 50
    },
    commonBottomBtnText: {
        fontSize: 12,
        color: '#000000'
    },
    commonBottomText: {
        fontSize: 14,

    },

    moreItemsBg: {
        position: 'absolute',
        width: '100%',
        height: '100%',
        // backgroundColor: 'rgba(0,0,0,0.3)'
    },
    moreItemsBox: {
        position: 'absolute',
        right: 8,
        top: 44,
        width: 150,
        height: 175,
        paddingTop: 44,
        flexDirection: 'column',
        alignItems: 'flex-end',
    },
    itemBox: {
        // width: '100%',
        height: 44,
        width: 108,
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
    },
    itemText: {
        marginRight: 10,
        color: '#000000',
        fontSize: 15
    },
    sepLine: {
        backgroundColor: '#E7E7E7',
        height: 0.5,
        width: 98,
        marginRight: 10,
    },

})